import BuffUtil from '@/BuffUtil';
import SelectUtil from '@/SelectUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 雷霆一击
 **/
export default class ZS_ThunderClap extends AbilityBase {
    static instance: ZS_ThunderClap;
    buffType: AppBuffType = {
        id: 'buff_ZS_ThunderClap',
        art: this.art,
        name: this.abilityName,
        ubertip: '受到雷霆一击的影响，攻击速度和移动速度降低',
        targetAttach: 'overhead',
        targetArt: 'Abilities\\Spells\\Orc\\StasisTrap\\StasisTotemTarget.mdl',
        isDebuff: true,
        dur: 8,
        attribute: {
            attackSpd_p: -0.2,
            move_speed_p: -0.2,
        },
    };
    constructor(id: string = 'Altj') {
        super(id);
        ZS_ThunderClap.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let es = SelectUtil.getEnemyUnitsInRange(source, 325);
        let lv = this.getAbilityLevel(source);
        let dmg = 45 * lv + UnitCommon.取攻击(source) * (0.75 + 0.45 * lv);
        for (let e of es) {
            DamageSystemInstance.applyEarthDamage(e, source, dmg, this.id);
            // BuffUtil.addBuff(e, this.buffType.id);
            BuffCommon.addBuff({ target: e, caster: source, buffTypeId: this.buffType.id, ablityId: this.id });
        }
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
